﻿using server;
using ServerFramework.Tool.Singleton;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace tcpserver
{
    public class CreateDataService: Singleton<CreateDataService>
    {
        private List<byte> list = new List<byte>();
        private List<string> times = new List<string>();
        public void Start()
        {
            Task task = new Task(TaskHandle);
            task.Start();
        }
        
        //没秒产生200条数据
        private int Count = 200;

        private int maxSize = 2000;
        public void TaskHandle()
        {
            while (true)
            {

                byte[] bytes = TestData.GetData();
                times.Add(TestData.time);
                if (list.Count > maxSize)
                {
                    list.RemoveAt(0);
                }
                list.AddRange(bytes);

                Thread.Sleep(5);
            }
        }

        public List<byte> Data
        {
            get
            {
                return list;
            }
        }

        public void ClearData()
        {
            list.Clear();
        }


       
    }
}
